<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/include/commonHeader::commonHeader('人员冲突列表')"></head>
<body class="gray-bg layer-blue">
<div class="wrapper wrapper-content animated fadeInRight full-container">
    <div class="row" id="container">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="btn-group table-tool" id="exampleToolbar" role="group">
                    <label class="pull-left" style="margin-top: 8px;"> 管理员:&nbsp&nbsp</label>
                   <select id="query_management"></select>
                   <!--     <option value="Y">是</option>
                        <option value="N">否</option>
                    </select>-->
                    <input id="query_userName" type="text" class="table-tool-btn pull-left"
                           placeholder="姓名/首字母"/>
                    <button type="button" onclick="reload()" class="btn btn-outline btn-success "
                            data-toggle="tooltip" title="刷新">
                        <i class="fa fa-refresh" aria-hidden="true"></i>
                    </button>
                </div>
                <table id="exampleTable" data-classes="table table-hover table-condensed">
                </table>
            </div>
        </div>
    </div>
</div>

<script src="/plugins/layer/layer.js"></script>
<script type="text/javascript">
    var p_edit = '';
</script>
<shiro:hasPermission name="crew:crewManagement:edit">
    <script type="text/javascript">
        p_edit = '';
    </script>
</shiro:hasPermission>

<!-- 自定义js -->
<script th:inline="javascript">
    var prefix = "/crewManagement";
    var dutyCode = "[[${dutyCode}]]".substr(1,1);

    $(function () {
        load();
    });
    function load() {
        var typeData = [{"id":"1","text":"是"},{"id":"0","text":"否"}];
        $("#query_management").select2({
            minimumResultsForSearch: Infinity,
            data:typeData,
            width:100
        });
        $('#exampleTable').bootstrapTable(
            {
                method: 'post',
                url: prefix + "/list.do",
                //iconSize: 'outline',
                toolbar: '#exampleToolbar',
                striped:true,
                showRefresh:true,
                dataType:'json',
                locale:"zh-CN",
                pagination:true,//是否分页
                pageList:[10,30,50],//可选每页页数
                pageSize:10,//每页记录行数
                pageNumber:1,//初始化加载第一页
                sidePagination:'server',//分页方式
                contentType: "application/x-www-form-urlencoded",
                queryParams: function (params) {
                    return {
                        cName: $("#query_userName").val(),
                        dutyCode: dutyCode,
                        management:$("#query_management").val(),
                        limit: params.limit,
                        offset: params.offset
                    };
                },
                onClickRow:function(row, $element){
                    $element.addClass('info').siblings().removeClass('info').end();
                },
                /*onDblClickRow: function (row, $element, field) {
                    view(row.id);
                },*/
                columns: [
                    {
                        field: 'idx',
                        formatter: orderFormatter,
                        title: '序号',
                        align: 'center',
                        width: '40'
                    },
                    {
                        field: 'depName',
                        title: '部门'
                    },
                    {
                        field: 'cname',
                        title: '人员'
                    },
                    {
                        field: 'techZName',
                        title: '排班授权'
                    },
                    {
                        field: 'management',
                        title: '是否是管理人员',
                        formatter: function (value,row) {
                            if(value == 1){
                                return "是";
                            }else {
                                return "否";
                            }
                        }
                    },
                    {
                        title: '操作',
                        align: 'center',
                        visible: isShowOperation(),
                        formatter: function (value, row, index) {
                            return [
                                '<a class="' + p_edit + '" href="#" title="编辑" onclick="edit(\'' + row.workcode + '\')">',
                                '<i class="glyphicon glyphicon-edit"></i>',
                                '</a>&nbsp;&nbsp;'
                            ].join('');
                        }
                    }]
            })
    }


    //刷新
    function reload() {
        $("#exampleTable").bootstrapTable('refresh');
    }

    function orderFormatter(value, row, index) {
        return index + 1;
    }

    function check(month,workcode,fullName){
        layer.open({
            type: 2,
            title: '管理干部维护',
            shadeClose: false, // 点击遮罩关闭层
            area: ['90%', '90%'],
            content: prefix + '/toEditPage.do?workcode=' + workcode,
        });
    }
    //编辑
    function edit(workcode) {
        layer.open({
            type: 2,
            title: '编辑',
            shadeClose: false, // 点击遮罩关闭层
            area: ['500px', '400px'],
            content: prefix + '/toEditPage.do?workcode=' + workcode
        });
    }
    //是否有权限显示 '操作' 列
    function isShowOperation() {
        return (p_edit != 'hidden');
    }
</script>
</body>
</html>